import { cn } from "@/lib/utils";
import * as LabelPrimitive from "@radix-ui/react-label";
import { cva } from "class-variance-authority";
import { forwardRef, Ref } from "react";

interface LabelProps extends LabelPrimitive.LabelProps {
  className?: string;
}

const defineClassName = cva(
  "text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
);

const Label = forwardRef(
  ({ className, ...props }: LabelProps, ref: Ref<HTMLLabelElement>) => (
    <LabelPrimitive.Root
      ref={ref}
      className={cn(defineClassName(), className)}
      {...props}
    />
  ),
);
Label.displayName = LabelPrimitive.Root.displayName;

export { Label };
